package com.hzgj.bcl.soa.command;

import com.google.common.collect.Maps;
import com.hzgj.bcl.soa.collector.JmxCollector;
import com.hzgj.bcl.soa.util.Constants;

import java.util.Map;

import static com.hzgj.bcl.soa.command.CommandsInitializer.BIZCOUNT_COMMAND;

/**
 * Created by Administrator on 2016/8/12.
 */
public class NodeBizCountCommand extends JmxInvokeCommand {

    @Override
    Map<String, Object> jmxInvoke(JmxCollector jmxCollector, CommandOptions commandOptions, String host, String port) {
        Map<String, Object> result = Maps.newHashMap();
        try {
            result.put("status", "success");
            result.put("bizcount", jmxCollector.invokeWithoutParam(Constants.getRpcServerObjectName(port), "getBizCount").toString());
        } catch (Exception e) {
            logger.error("{}", e);
            result.put("count", 0);
            result.put("status", "failure");
            result.put("msg", e.getMessage());
        }
        return result;
    }

    @Override
    public String getName() {
        return BIZCOUNT_COMMAND;
    }
}
